Skip to content

WIP: TDF/OCAF bindings PoC#222

Open
Ben-PH wants to merge 4 commits intobschwind:mainfrom
Ben-PH:Tdf_Poc
Open

WIP: TDF/OCAF bindings PoC#222
Ben-PH wants to merge 4 commits intobschwind:mainfrom
Ben-PH:Tdf_Poc

Conversation

@Ben-PH
Copy link
Copy Markdown

@Ben-PH Ben-PH commented Apr 15, 2026

Adds Rust bindings for OCCT's TDF and TNaming subsystems, surfacing stable topological shape identity across model operations. This allows for applications to be developed in accordance with OCCT expectations, and avoiding preventable topo-naming nightmares.

Work is incomplete, and the proposed API would benefit from the careful attention of an experienced eye in review.

What's in

  • TDF_Data, TDF_Label, TDF_Transaction, TDF_Delta with lifetime-enforced ownership chain — 'doc lifetime prevents labels and transactions outliving their document, enforced at compile time
  • TDF_Data::Undo with consume-by-value delta semantics — applying a delta is a one-way operation; the inverse (redo) delta is returned
  • TNaming_Builder bindings — Generated (with and without predecessor), Modify, Delete, Select — exposed through a safe Rust API taking &Shape rather than raw &TopoDS_Shape
  • TnamingBuilder borrows the open TdfTransaction for its full lifetime — the borrow checker prevents committing while a builder is live
  • TnamingNamedShape::get() returning the current active shape, and original_shape() returning the recorded old shape — both coherent across undo/redo boundaries
  • Shape::translation() -> DVec3 for location querying without leaking FFI types
  • Full undo/redo round-trip test asserting active shape state at each stage via get()
  • Compile-fail doc-tests demonstrating lifetime constraints

Known gaps flagged in comments

  • TdfTransaction::open return value needs newtyping (nested transaction index)
  • Builder construction on an unopened transaction cannot be enforced by the borrow checker — future closure-based API will make this impossible to misorder
  • build.rs link additions for TDF/TNaming libraries may be needed depending on build configuration

Disclaimer: Much of this work was done with a lot of heavy lifting coming from LLM assistance, but without LLM directly touching the codebase.

@Ben-PH Ben-PH marked this pull request as draft April 15, 2026 22:17
@Ben-PH Ben-PH marked this pull request as ready for review April 16, 2026 12:49
@Ben-PH Ben-PH mentioned this pull request Apr 16, 2026
@Ben-PH
Copy link
Copy Markdown
Author

Ben-PH commented Apr 16, 2026

Before having solic confidence in these changes, I'll make use of the in my cad application. That should be completed within a day or two

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant